<?
// เชื่่อมต่อฐานข้อมูล
$host="localhost"; // กำหนด host
$username="root"; // กำหนด username
$pass_word="root"; // กำหนด Password
$db="database"; // กำหนดชื่อฐานข้อมูล
$Conn = mysql_connect( $host,$username,$pass_word) or die ("ติดต่อฐานข้อมูลไม่ได้");// ติดต่อฐานข้อมูล
mysql_query("SET NAMES utf8",$Conn); // set กำหนดมาตราฐาน
mysql_select_db($db) or die("เลือกฐานข้อมูลไม่ได้"); // เลือกฐานข้อมูล 

$Per_Page = 4;   // Per Page

$Page = $_GET["Page"];
if(!$_GET["Page"])
{
	$Page=1;
}

$Prev_Page = $Page-1;
$Next_Page = $Page+1;

$Page_Start = (($Per_Page*$Page)-$Per_Page);
if($Num_Rows<=$Per_Page)
{
	$Num_Pages =1;
}
else if(($Num_Rows % $Per_Page)==0)
{
	$Num_Pages =($Num_Rows/$Per_Page) ;
}
else
{
	$Num_Pages =($Num_Rows/$Per_Page)+1;
	$Num_Pages = (int)$Num_Pages;
}

$strSQL .=" order  by clinic_id DESC LIMIT $Page_Start , $Per_Page";
$objQuery  = mysql_query($strSQL);
 
?>



<!DOCTYPE HTML>
<html lang="en-US">
<head>
    <meta charset="UTF-8">
    <title> BeautyClinic  </title>

<!-- Linking styles -->
<link rel="stylesheet" href="css/screen.css" type="text/css" media="screen" title="default" />
    
<!-- Start ------ Select Zone Town Amphur -->
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript">
$(function(){
 	$("#town_id").change(function(){
	
		var url = "Select_town/amphur.php?town_id="+$(this).val() ;

		$.getJSON(
				url ,
				function(resp){
					var opt = "<option value='0'>-- อำเภอ --</option>";
					
					for(var i=0;i<resp.length;i++){
						opt += "<option value='"+ resp[i].amphur_id+"'>"+resp[i].amphur_name+"</option>";
					}
					$("#amphur_id").html( opt );
				} 
		);
	});
})
</script>

<script type="text/javascript">
$(function(){
 	$("#amphur_id").change(function(){
	
		var url = "Select_town/tambon.php?amphur_id="+$(this).val() ;

		$.getJSON(
				url ,
				function(resp){
					var opt = "<option value='0'>-- ตำบล --</option>";
					
					for(var i=0;i<resp.length;i++){
						opt += "<option value='"+ resp[i].tambon_id+"'>"+resp[i].tambon_name+"</option>";
					}	
					$("#tambon_id").html( opt );
				} 
		);
	});
})
</script>
<!-- End ------ Select Zone Town Amphur -->


 </head>





<body>
<!-- Menu -->
    <header>
    <div class="marg">
        <div class="header">
 
	<!--  START Header -->
	<div id="Header">
			<!-- Start: page-top --> 	
			<div id="page-top"> </div>
			<!-- End: page-top -->
		<div class="clear">&nbsp;</div>
	</div>
	<!-- End: Header -->



	
 
<!--  START nav-outer-repeat -->
<div class="nav-outer-repeat"> 

<!--  ............. START main .............  -->
<div id ="main">

	<!--  start nav-outer -->
	<div class="nav-outer"> 
		<!-- start nav-right -->
		<div id="nav-right">	
				<? if(isset($_COOKIE["USER"]) == false){ ?>
					<div class="nav-divider-right">&nbsp;</div>

 					 <a href="./login.php"><img src="images/shared/login.png" alt="" /></a> 

					<div class="nav-divider-right">&nbsp;</div>

					 <a href="./signup.php"> <img src="images/shared/signup.png" alt="" /></a> 
		 
 					<div class="nav-divider-right">&nbsp;</div>
                <? } else{ ?>
					<div id="member-form">
						<div class="nav-divider-right">&nbsp;</div>

  						<a href="./logout.php"> <img src="images/shared/logout.png" alt="" /> </a> 
	
  						<div class="nav-divider-right">&nbsp;</div>
	
 						<div class="member-bar-form"><a>  ยินดีต้อนรับ คุณ  <u>  <?=$_COOKIE["USER"]?>    </u>  </a>  </div>
				  
						 <div class="nav-divider-right">&nbsp;</div>
					</div>
            <? } ?>

  
				<div class="clear">&nbsp;</div>		 
		</div> <!--  END nav-right -->


		<!--  start nav left-->
		<div class="nav">
		<div class="table">
				<div class="nav-divider">&nbsp;</div>
				
				<ul class="select"><li> <a href="./index.php"> <b> หน้าหลัก </b> </a> </li></ul>
				<div class="nav-divider">&nbsp;</div>
								
				<ul class="select"><li> <a href="./clinic.php"> <b> ศูนย์ศัลยกรรม </b> </a> </li></ul>
				<div class="nav-divider">&nbsp;</div>
			
				<ul class="select"><li><a href="./doctor.php"> <b> ศัลยแพทย์ </b> </a> <!--[if lte IE 6]></td></tr></table></a><![endif]--> </li> </ul>
				<div class="nav-divider">&nbsp;</div>
			
				<ul class="select"><li><a href="#nogo"> <b> รีวิวการศัลยกรรม </b> </a> </li> </ul>
				<div class="nav-divider">&nbsp;</div>		
				
				<ul class="select"><li><a href="#nogo"> <b> ศัลย์วาไรตี้ </b> </a> </li> </ul>
				<div class="nav-divider">&nbsp;</div>
	 
				<div class="clear"></div>
		</div> <!--  END table -->

				<div class="clear"></div>	
		</div> <!--  END nav -->
</div>
<!--  ............. END main .............  -->

			<div class="clear"></div>
	</div> <!--  END nav-outer -->

</div>
<!--  END nav-outer-repeat -->

  

<!--  ..... start content-bg --- M A P .....  -->
<div id="content-bg">
<!-- 
<div id="map"><iframe width="100%" height="250" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps?f=q&amp;source=s_q&amp;hl=en&amp;geocode=&amp;q=+%E0%B8%AD.%E0%B9%80%E0%B8%A1%E0%B8%B7%E0%B8%AD%E0%B8%87%E0%B8%9E%E0%B8%B4%E0%B8%A9%E0%B8%93%E0%B8%B8%E0%B9%82%E0%B8%A5%E0%B8%81+%E0%B8%88.%E0%B8%9E%E0%B8%B4%E0%B8%A9%E0%B8%93%E0%B8%B8%E0%B9%82%E0%B8%A5%E0%B8%81+%E0%B8%9B%E0%B8%A3%E0%B8%B0%E0%B9%80%E0%B8%97%E0%B8%A8%E0%B9%84%E0%B8%97%E0%B8%A2&amp;aq=t&amp;sll=16.816134,100.262389&amp;sspn=0.010578,0.018475&amp;ie=UTF8&amp;hq=&amp;hnear=Mueang+Phitsanulok,+Phitsanulok,+Thailand&amp;ll=16.819922,100.262500&amp;spn=0.010578,0.018475&amp;t=m&amp;z=15&amp;output=embed" ></iframe></div>

<div class="clear">&nbsp;</div>
 -->
</div>
<!--  ..... end content-bg --- M A P ..... -->




<!--  ............. START bar_map .............   
		<div id="bar_map">
				<div id="bar_map1"> </div>
		</div>
<!--  ............. END bar_map .............  -->





<!--  ............. START main .............  -->
<div id ="main">
 							
  
<!-- start container -- จัดกลาง -->
<div id="container">

	
	<div id="search_web">	
 <!--  START --- S e a r c h --->
 
<form id="form1" name="form1" method="post" action="search.php">

			<div class="titles"> <img src="./images/shared/search_text.png"   /> </div>
 
			<table border="0" width="" cellpadding="0" cellspacing="0" id="form_search" >

				<tr>
					<th valign="middle" colspan="6">Find on BeautyClinic :</th>
				</tr>
				
				<tr>					 
					<td colspan="6"><input type="text" name="txt_search"  value="<?=$_POST['txt_search']?>"  placeholder=" ค้นหา ศูนย์ศัลยกรรม หรือ ศัลยแพทย์ ที่นี่ "       class="search" /></td>
					<td > <input type="submit" name="Search" class="btn_search" value="ค้นหา" /> </td>
				</tr>

				<tr><td colspan=6> &nbsp;   </td></tr>

				<tr>
					<th valign="middle" for="town_id">จังหวัด </th>
					<td>	
							<select name="town_id" id="town_id" class="selectbox">
									<option value="0">-- เลือกจังหวัด --</option>
								<?php while( $row_rs_town= mysql_fetch_assoc($rs_town) ) : ?>
									<option value="<?php echo $row_rs_town['town_id']?>"><?php echo $row_rs_town['town_name']?></option>
								<?php endwhile ;?>
							</select>
					</td>
 
 
 					<th valign="middle" for="amphur_id">อำเภอ </th>
					<td>	
							<select name="amphur_id" id="amphur_id" class="selectbox">
									<option value="0">-- เลือกอำเภอ --</option>
								<?php while( $row_rs_amphur = mysql_fetch_assoc($rs_amphur) ) : ?>
									<option value="<?php echo $row_rs_amphur['amphur_id']?>"><?php echo $row_rs_amphur['amphur_name']?></option>
								<?php endwhile ;?>
							</select>
					</td>

 					<th valign="middle" for="tambon_id">ตำบล </th>
					<td>	
							<select name="tambon_id" id="tambon_id" class="selectbox">
									<option value="0">-- เลือกตำบล --</option>
							</select>
					</td>
				</tr>

			</table>
</form>

	 </div>		<!--  END --- S e a r c h --> 


 


<!--  START --- C o n t e n t --> 
<div id="content">

 
<div class="left">    <!--  START --- C o n t e n t --- left -->

<div class="clinic_title">
	<div class = "toptitle_bar">  </div> 
	<div class = "toptitle_clinic_inbc">  </div>
</div>

 	<div class="side_doctor_etc"> 	<!--  START --------------------------------- Clinic SHOW etc -->	

<? 
$sql_show = "SELECT * FROM clinic,tbl_amphur,tbl_tambon " ;
if($_POST['Search'])
{
	$txt_search = $_POST['txt_search'];
	$sql_show.=" where clinic_name like '%$txt_search%'  and clinic.amphur_id = tbl_amphur.amphur_id and clinic.tambon_id = tbl_tambon.tambon_id  ";
}
	$result_show = mysql_query($sql_show) or die(mysql_error());
while($row_show = mysql_fetch_array($result_show) )
{
?>	
  <div class="sidebar_doctor_etc">    <!--  start sidebar_doctor_show -->
 			<ul> <a href="clinicshow.php?clinic_id=<?=$row_show["clinic_id"];?>"> 			
				<img src="myfile/<?=$row_show["clinic_pic"];?>" class="siderightpost_clinic" />
<table border="0" > <tr> 
		<td  width="360px">
					<li>  <h3> <?=$row_show["clinic_name"];?>    </h3></li>
  				<li> <img src="./images/shared/review/clinic.png">  ศูนย์ศัลยกรรม <?=$row_show["clinic_name"];?>    </li>
 					<li> พื้นที่ :  ต.<?=$row_show["tambon_name"];?> อ.<?=$row_show["amphur_name"];?>        </li>  
					<li>  &nbsp;     </li>  
				</a>
			</ul>
		</td>   
		<td align="right" width="220px">
			<ul>
				<li> &nbsp;  </li>	<li> &nbsp; </li>	<li> &nbsp; </li> 
 				<li>   <img src="./images/shared/review/comment.png"> 1 reviews </li>
 			</ul>
		</td>
</tr> </table>   
</div>	  <!--  end sidebar_doctor_show etc -->
<? } ?>		



<? 
$sql_show2 = "SELECT * FROM doctor " ;
if($_POST['Search'])
{
	$txt_search = $_POST['txt_search'];
	$sql_show2 .= "where dr_name like '%$txt_search%' " ;
}
	$result_show2 = mysql_query($sql_show2) or die(mysql_error());
while($row_show2 = mysql_fetch_array($result_show2))
{
?>	
 	 
  <div class="sidebar_doctor_etc">    <!--  start sidebar_doctor_show -->
 			<ul> <a href="doctorshow.php?dr_id=<?=$row_show2["dr_id"];?>"> 			
				<img src="myfile/<?=$row_show2["dr_pic"];?>" class="siderightpost_clinic" />
<table border="0" > <tr> 
		<td  width="360px">
					<li>  <h3> <?=$row_show2["dr_name"];?>    </h3></li>
  				<li> <img src="./images/shared/review/clinic.png">  ศูนย์ศัลยกรรม <?=$row_show2["clinic_name"];?>    </li>
 					<li> พื้นที่ :  ต.<?=$row_show2["tambon_name"];?> อ.<?=$row_show2["amphur_name"];?>        </li>  
					<li>  &nbsp;     </li>  
				</a>
			</ul>
		</td>   
		<td align="right" width="220px">
			<ul>
				<li> &nbsp;  </li>	<li> &nbsp; </li>	<li> &nbsp; </li> 
 				<li>   <img src="./images/shared/review/comment.png"> 1 reviews </li>
 			</ul>
		</td>
</tr> </table>   
</div>	  <!--  end sidebar_doctor_show etc -->

 <? } ?>		



 <?
if($Prev_Page)
{
	echo " <a href='$_SERVER[SCRIPT_NAME]?Page=$Prev_Page'>ย้อนกลับ </a> ";
}

 for($i=1; $i<=$Num_Pages; $i++){
	if($i != $Page)
	{
		echo "  <a href='$_SERVER[SCRIPT_NAME]?Page=$i'> <u> $i  </u> </a>    ";
 	}
	else
	{
		echo "   <a> <b> $i </b> </a>";
 	}
}
if($Page!=$Num_Pages)
{
	echo " <a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page'> ถัดไป</a> ";
}
mysql_close($Conn);
?>  
 		 
		
	</div>   <!--  End --- Doctor SHOW etc -->	
</div>   <!--  End --- left -->	

</div>  <!--  end left -->















</div>

 <!-- start footer -->         
<div id="footer">
<!-- <div id="footer-pad">&nbsp;</div> -->
	<!--  start footer-left -->
	<div id="footer-left"> Contact : beautyclinic@info	
	  <a href="">BeautyClinic &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a>.</div>
	<!--  end footer-left -->
 </div>
<!-- end footer -->

 

</div>
<!--  end content -->


</div>
<!--  end container -->

  


 
 </div>
<!-- END   ........................................................................................................................ END MAIN -->


</body>
</html>